package com.wangbo.apollo;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import lombok.SneakyThrows;

public class TestAPI {

    public static void main(String[] args) {
        test02();
    }

    /**
     * 测试实时修改配置
     */
    @SneakyThrows
    public static void test01() {
        Config namespace = ConfigService.getAppConfig();
        while (true) {
            String value = namespace.getProperty("my.name", null);
            System.out.println(value);
            Thread.sleep(3000L);
        }
    }

    /**
     * 指定 namespace
     */
    public static void test02() {
        Config namespace = ConfigService.getConfig("namespace02.yml");
        String value = namespace.getProperty("my.app.name", null);
        System.out.println(value);
    }
}
